using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using m.Channelvn.Cached.Common;


namespace Website.Controls_T
{
    public partial class Header : System.Web.UI.UserControl
    {
        private const string CAT_FORMAT = "<a href='{0}'>{1}</a>";
        protected string html = string.Empty;
        public int type = 0;
        public int catID = 0;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                catID = Lib.QueryString.CategoryID;
                int catParentID = Lib.QueryString.CategoryParentID;
                type =  String.IsNullOrEmpty(Request.QueryString["type"]) ? 0 : Convert.ToInt32(Request.QueryString["type"]);
                if (catParentID == 0)
                {
                    //CategoryEntity ct = BONewsPublished.Category(catID);
                    //ltrCatName.Text = string.Format(CAT_FORMAT, ct.Href, ct.CatName);
                    Page.ClientScript.RegisterHiddenField("hidCat", catID.ToString());
                }
                else
                {
                    //CategoryEntity ct = BONewsPublished.Category(catParentID);
                    //ltrCatName.Text = string.Format(CAT_FORMAT, ct.Href, ct.CatName);
                    Page.ClientScript.RegisterHiddenField("hidCat", catParentID.ToString());
                }
                //if (catID == 0 && catParentID == 0)
                    //ltrCatName.Text = string.Format(CAT_FORMAT, "/home.htm", "Trang chủ");

                #region Bind ListCategory
                //DataTable dt = BusinessObjectProject_T.BONewsPublished.GetCategory();
                //if (dt != null && dt.Rows.Count > 0)
                //{
                //    html = "<select id='select_list' onchange='redirect()'>";
                //    html += "<option value='/home.htm'>Trang chủ</option>";
                //    DataRow dr;
                //    for (int i = 0; i < dt.Rows.Count; i++)
                //    {
                //        dr = dt.Rows[i];
                //        if (catParentID == 0)
                //        {
                //            if (dr["Cat_ID"].ToString() == catID.ToString())
                //                html += "<option selected='selected' value='/p0c" + dr["Cat_ID"].ToString() + "/" + dr["Cat_DisplayURL"].ToString() + ".htm'>" + dr["Cat_Name"] + "</option>";
                //            else
                //                html += "<option value='/p0c" + dr["Cat_ID"].ToString() + "/" + dr["Cat_DisplayURL"].ToString() + ".htm'>" + dr["Cat_Name"] + "</option>";
                //        }
                //        else
                //        {
                //            if (dr["Cat_ID"].ToString() == catParentID.ToString())
                //                html += "<option selected='selected' value='/p0c" + dr["Cat_ID"].ToString() + "/" + dr["Cat_DisplayURL"].ToString() + ".htm'>" + dr["Cat_Name"] + "</option>";
                //            else
                //                html += "<option value='/p0c" + dr["Cat_ID"].ToString() + "/" + dr["Cat_DisplayURL"].ToString() + ".htm'>" + dr["Cat_Name"] + "</option>";
                //        }
                //    }
                //    html += "</select>";
                //}
                #endregion
            }
        }
    }
}